#include "tetris_hint.h"
namespace Tetris{

Tetris_NextShape::Tetris_NextShape(int left,int top,UI::UI_Window* parent): UI::UI_Window(UI::UI_Rect(left,top,left + 1,top + 1),parent){
	this->SetBackground("data/image/hint.png");
}
void Tetris_NextShape::SetShape(const Shape* p_shape){
	this->ClearSurface();
	UI::KTV_Draw* p_draw = UI::UI_Application::Instance()->GetDrawTextObj();
	int x = 14 + (100 - (p_shape->GetMaxX() - p_shape->GetMinX() + 1) * Table::BLOCK_SIZE) / 2;
	int y = 14 + (100 - (p_shape->GetMaxY() - p_shape->GetMinY() + 1) * Table::BLOCK_SIZE) / 2;
	for(int i=0;i<p_shape->Row();++i){
		for(int j=0;j<p_shape->Column();++j){
			if(p_shape->GetValue(j,i)){
				SDL_Surface* surface = p_draw->GetFromImageFile("data/image/color" + stdex::itoa(p_shape->ColorStyle()) +".bmp");
				this->DrawSurface(surface,UI::UI_Point(x + (j - p_shape->GetMinX()) * Table::BLOCK_SIZE,y + (i - p_shape->GetMinY()) * Table::BLOCK_SIZE));
			}
		}
	}
}

Tetris_Score::Tetris_Score(int left,int top,UI::UI_Window* parent): UI::UI_Window(UI::UI_Rect(left,top,left + 1,top + 1),parent){
	this->SetBackground("data/image/score.png");
}

void Tetris_Score::ShowScore(int score){
	this->ClearSurface();
	UI::KTV_Draw* p_draw = UI::UI_Application::Instance()->GetDrawTextObj();
	this->DrawSurface(p_draw->DrawUTF8_Solid(stdex::itoa(score),UI::COLOR_GREEN,33,0),UI::UI_Point(20,37));
	this->DrawSurface(p_draw->DrawUTF8_Solid(stdex::itoa(score / 100 + 1),UI::COLOR_GREEN,33,0),UI::UI_Point(85,37));
}

Tetris_Player::Tetris_Player(int left,int top,UI::UI_Window* parent): UI::UI_Window(UI::UI_Rect(left,top,left + 1,top + 1),parent){
	this->SetBackground("data/image/player.png");
}

void Tetris_Player::ShowPlayer(const std::string& player){
	this->ClearSurface();
	UI::KTV_Draw* p_draw = UI::UI_Application::Instance()->GetDrawTextObj();
	this->DrawSurface(p_draw->DrawUTF8_Solid(player,UI::COLOR_GREEN,25,0),UI::UI_Point(28,60));
}

Tetris_Notice::Tetris_Notice(int left,int top,UI::UI_Window* parent): UI::UI_Window(UI::UI_Rect(left,top,left + 1,top + 1),parent){
	this->SetBackground("data/image/notice.png");
}

void Tetris_Notice::ShowNotice(const std::string& notice){
	this->ClearSurface();
	UI::KTV_Draw* p_draw = UI::UI_Application::Instance()->GetDrawTextObj();
	this->DrawSurface(p_draw->DrawUTF8_Solid(notice,UI::COLOR_GREEN,20,0),UI::UI_Point(23,50));
}

}